package com.wude.guild.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.wude.bean.CouponListBean;
import com.wude.guild.holder.CouponHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述：优惠券Adapter
 * 时间: 2017-09-05 13:54
 */
public class ListCouponAdapter extends BaseAdapter {

    private Activity activity;
    public List<CouponListBean.DataBean> listCoupon = new ArrayList<>();

    public ListCouponAdapter(Activity activity) {
        this.activity = activity;
    }

    public List<CouponListBean.DataBean> getListCoupon() {
        return listCoupon;
    }

    public void setListCoupon(List<CouponListBean.DataBean> listCoupon) {
        this.listCoupon = listCoupon;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return listCoupon.size();
    }

    @Override
    public Object getItem(int position) {
        return listCoupon.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        CouponHolder holder = null;
        if (convertView == null) {
            holder = new CouponHolder();
        } else {
            holder = (CouponHolder) convertView.getTag();
        }
        CouponListBean.DataBean couponBean = listCoupon.get(position);
        holder.setData(couponBean, position, activity);
        return holder.getContentView();
    }
}
